package com.probox.common.entity.domain.product.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.probox.common.entity.domain.customer.CustomerLabel;
import com.probox.common.entity.domain.product.ProductBrand;
import com.probox.common.entity.domain.product.ProductCategory;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * select结构实体类
 *
 *
 */
public class OptionsSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点value */
    private Long value;

    /** 节点名称 */
    private String label;

    private Long groupUid;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<OptionsSelect> children;

    public OptionsSelect()
    {

    }

    public OptionsSelect(ProductBrand productBrand){
        this.value = productBrand.getBrandUid();
        this.label = productBrand.getBrandName();
    }

    public OptionsSelect(ProductCategory productCategory)
    {
        this.value = productCategory.getCategoryUid();
        this.label = productCategory.getCategoryName();
        this.groupUid = productCategory.getGroupUid();
        this.children = productCategory.getChildren().stream().map(OptionsSelect::new).collect(Collectors.toList());
    }



    public OptionsSelect(CustomerLabel customerLabel)
    {
        this.value = customerLabel.getLabelId();
        this.label = customerLabel.getLabelName();
        this.children = customerLabel.getChildren().stream().map(OptionsSelect::new).collect(Collectors.toList());
    }


    public Long getValue() {
        return value;
    }

    public void setValue(Long value) {
        this.value = value;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public List<OptionsSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<OptionsSelect> children)
    {
        this.children = children;
    }

    public Long getGroupUid() {
        return groupUid;
    }

    public void setGroupUid(Long groupUid) {
        this.groupUid = groupUid;
    }
}
